package cn.zane.gateway.datasource.unpooled;

import cn.zane.gateway.datasource.DataSource;
import cn.zane.gateway.datasource.DataSourceFactory;
import cn.zane.gateway.datasource.DataSourceType;
import cn.zane.gateway.session.Configuration;

/**
 * 无池化的数据源工厂
 * @author zane
 * @since 2024-09-10
 */
public class UnPooledDataSourceFactory implements DataSourceFactory {

    protected UnPooledDataSource dataSource;

    public UnPooledDataSourceFactory() {
        this.dataSource = new UnPooledDataSource();
    }

    @Override
    public void setProperties(Configuration configuration, String uri) {
        this.dataSource.setConfiguration(configuration);
        this.dataSource.setDataSourceType(DataSourceType.DUBBO);
        this.dataSource.setHttpStatement(configuration.getHttpStatement(uri));
    }

    @Override
    public DataSource getDataSource() {
        return dataSource;
    }
}
